/**
 * @author: ZhongXu
 * @date:2017-06-22
 */
$(document).ready(
    function() {
        var VAL = {
            NORMAL : "0000000",
            T_FPPFORCEIN : "FPPFORCEIN",
            T_FBPSWHPTH : "FBPSWHPTH",
            T_FIPINQSHT : "FIPINQSHT",
            T_FBPBISPTH : "FBPBISPTH",
            T_FBPLSTDAT : "FBPBISDAT",
            EVT_USER :$("#userId").text(),
            DISABLED_ATTR : {
                'disabled' : true
            },
            ENABLED_ATTR : {
                'disabled' : false
            }
        };
        var domObj = {
            $prdSeqIdFk : $("#prdSeqIdFk"),
            $frPathIdFk : $("#frPathIdFk"),

            $prdSeqId   : $("#prdSeqId"),
            $prdStat    : $("#prdStat"),
            $prdGrade   : $("#prdGrade"),
            $mdlIdFk    : $("#mdlIdFk"),
            $woIdFk     : $("#woIdFk"),
            $crOpeNoFk  : $("#crOpeNoFk"),
            $nxOpeNoFk  : $("#nxOpeNoFk"),
            $nxProcIdFk : $("#nxProcIdFk"),
            $nxPathIdFk : $("#nxPathIdFk"),
            $nxPathVerFk: $("#nxPathVerFk"),
            $crPathIdFk: $("#crPathIdFk"),
            $crPathVerFk: $("#crPathVerFk"),
            buttons : {
                $query_btn : $("#query_btn"),
                $selectReason_btn : $("#selectReason_btn"),
                $deleteReason_btn : $("#deleteReason_btn"),
                $reWork_btn : $("#reWork_btn"),
                $delReWork_btn : $("#delReWork_btn"),
                $stopReWork_btn : $("#stopReWork_btn"),
            },
            grids : {
                $reasonListGrd : $("#reasonListGrd"),
                $reasonListDiv : $("#reasonListDiv"),
                $reasonListPg : $("#reasonListPg"),

                $glassListGrd : $("#glassListGrd"),
                $glassListDiv : $("#glassListDiv"),
                $glassListPg : $("#glassListPg")
            },
            dialogs : {
                $addReasonDialog : $("#addReasonDialog"),
                $rePathDialog : $("#rePathDialog"),

                $deptId : $("#deptId"),

                $modalReasonListDiv : $("#modalReasonListDiv"),
                $modalReasonListGrd : $("#modalReasonListGrd"),
                $modalReasonListPg : $("#modalReasonListPg"),

                $reModalReasonListDiv : $("#reModalReasonListDiv"),
                $reModalReasonListGrd : $("#reModalReasonListGrd"),
                $reModalReasonListPg : $("#reModalReasonListPg"),

                // 对话框的确认按钮
                $reasonDialog_sureBtn : $("#reasonDialog_sureBtn"),
                $rePathDialog_sureBtn : $("#rePathDialog_sureBtn"),

                $rePathListDiv : $("#rePathListDiv"),
                $rePathListGrd : $("#rePathListGrd"),
                $rePathListPg : $("#rePathListPg"),

            }

        }
        var toolFunc ={
            iniRewokPath : function() {
                var iary = {
                    path_cate : 'RWK'
                }
                var inObj={
                    trx_id : VAL.T_FBPBISPTH,
                    action_flg : "Q",
                    iaryA : [iary]
                }
                var outObj = comTrxSubSendPostJson(inObj);
                if (outObj.rtn_code === VAL.NORMAL) {
                    setGridInfo(outObj.oaryA, "#rePathListGrd");
                }
            }
        }
        var btnFunc = {
            queryBtnfunc : function() {
                var prdSeqIdFk,  inObj, outObj;
                prdSeqIdFk = $.trim(domObj.$prdSeqIdFk.val());
                if (! prdSeqIdFk) {
                    showErrorDialog("", "屏体代码不能为空");
                    return false;
                }
                var rowDatas = domObj.grids.$glassListGrd.jqGrid("getRowData");
                if(rowDatas.length>0){
                    for (var i = 0; i < rowDatas.length; i++) {
                        if ($.trim(rowDatas[i].prd_seq_id) == prdSeqIdFk ) {
                            showErrorDialog("", "["+prdSeqIdFk+"]屏体信息已经存在列表中");
                            domObj.$prdSeqId.val("");
                            return false;
                        }
                    }
                }
                inObj={
                    trx_id : VAL.T_FIPINQSHT,
                    action_flg : "Q",
                    prd_seq_id : prdSeqIdFk
                }
                outObj = comTrxSubSendPostJson(inObj);
                if (outObj.rtn_code === VAL.NORMAL) {
                    if(outObj.prd_stat=="WAIT"){
                        var ids = domObj.grids.$glassListGrd.jqGrid('getDataIDs');
                        if(ids.length>0){
                            var rowData = domObj.grids.$glassListGrd.jqGrid("getRowData",ids[0]); //获取第一条数据。。
                             if(outObj.wo_id_fk!=rowData.wo_id_fk){
                                 showErrorDialog("", "工单信息不一致");
                                 return false;
                             }
                             if(outObj.mdl_id_fk!=rowData.mdl_id_fk){
                                 showErrorDialog("", "产品信息不一致");
                                 return false;
                             }
                             if(outObj.path_id_fk!=rowData.path_id_fk){
                                 showErrorDialog("", "工艺路线不一致");
                                 return false;
                             }
                             if(outObj.ope_id_fk!=rowData.ope_id_fk){
                                 showErrorDialog("", "站点信息不一致");
                                 return false;
                             }
                            var data = outObj
                            var newRowId = getGridNewRowID("#glassListGrd");
                            domObj.grids.$glassListGrd.jqGrid("addRowData", newRowId, data);
                        }else {//第一条数据直接添加
                            var data = outObj
                            var newRowId = getGridNewRowID("#glassListGrd");
                            domObj.grids.$glassListGrd.jqGrid("addRowData", newRowId, data);

                        }
                    }else {
                        showErrorDialog("", "ID["+prdSeqIdFk+"]屏体状态不是WAIT");
                        return false;
                    }
                }
            },
            selectReasonBtnfunc : function() {
                domObj.dialogs.$modalReasonListGrd
                    .jqGrid("clearGridData");
                domObj.dialogs.$reModalReasonListGrd
                    .jqGrid("clearGridData");
                // 原因代码对话框的模型
                domObj.dialogs.$addReasonDialog.modal({
                    backdrop : true,
                    keyboard : false,
                    show : false
                });
                domObj.dialogs.$addReasonDialog.modal("show");
                // 初始化部门代码
                comAddValueByDataCateFnc(domObj.dialogs.$deptId, "DEPT", "data_ext", "data_desc", true);
                // 初始化原因代码
                var  iary, inObj, outObj;
                iary = {
                    data_cate : "RKRS",
                };
                inObj = {
                    trx_id : VAL.T_FBPLSTDAT,
                    action_flg : "Q",
                    iary : [ iary ]
                };
                outObj = comTrxSubSendPostJson(inObj);
                if (outObj.rtn_code === VAL.NORMAL) {
                    var deptIds = domObj.dialogs.$deptId.val();
                    var oary = [];
                    for (var i = 0; i < outObj.oary.length; i++) {
                        var reason = {};
                        reason.deptId = deptIds;
                        reason.data_ext = outObj.oary[i].data_ext;
                        reason.data_desc = outObj.oary[i].data_desc;
                        oary.push(reason);
                    }
                    setGridInfo(oary,"#modalReasonListGrd");
                }
            },
            deleteReasonBtnfunc : function() {
                var selRowId = domObj.grids.$reasonListGrd.jqGrid(
                    "getGridParam", "selrow");
                if (selRowId.length < 1) {
                    showErrorDialog("", "请至少选择一条原因代码进行删除");
                }
                $("#deleteReason_btn").showCallBackWarnningDialog(
                    {
                        errMsg : "是否删选原因代码,请确认!!!!",
                        callbackFn : function(data) {
                            if (data.result == true) {
                                // 动态删除jqgrid行时，数据会在动态变化
                                var length = selRowId.length;
                                for (var i = 0; i < length; i++) {
                                    domObj.grids.$reasonListGrd.jqGrid("delRowData",selRowId[0]);
                                }
                            }
                        }
                    });
            },
            reWorkBtnfunc: function() {
                var iaryA,inObj,outObj;//查询在不在主途程上
                var rowIds = domObj.grids.$glassListGrd.jqGrid("getGridParam","selarrrow");
                var data = new Array();
                for (var i=0;i<rowIds.length;i++){
                    var rowData = domObj.grids.$glassListGrd.jqGrid("getRowData",rowIds[i]);
                    data.push(rowData)
                }
                if (data.length<1) {
                    showErrorDialog("", "至少选中一条屏体信息");
                    return false;
                }
                iaryA = {
                    path_id : domObj.$nxPathIdFk.val(),
                    path_ver : domObj.$nxPathVerFk.val()
                };
                inObj = {
                    trx_id : VAL.T_FBPBISPTH,
                    action_flg : "Q",
                    iaryA : [ iaryA ]
                };
                outObj = comTrxSubSendPostJson(inObj);
                if (outObj.rtn_code === VAL.NORMAL) {
                    if(outObj.oaryA[0].path_cate!='MAN'){
                        showErrorDialog("", "屏体不在主流程上，无法进行重工操作");
                        return false;
                    }
                }
                var nxPathIdFk, nxPathVerFk,nxOpeNoFk,rePathId,rePathVerk,
                    rsnCate,rsnCode,rsnDept;
                var reasonRowData =domObj.grids.$reasonListGrd.jqGrid("getRowData");
                if(reasonRowData.length<1){
                    showErrorDialog("", "原因代码不能为空");
                    return;
                }
                var rowId= domObj.dialogs.$rePathListGrd.jqGrid("getGridParam", "selrow");
                var pathRowData = domObj.dialogs.$rePathListGrd.jqGrid("getRowData",rowId);
                if(rowId==null){
                    showErrorDialog("", "重工代码不能为空");
                    return;
                }
                rePathId = pathRowData.path_id;
                if (!rePathId) {
                    showErrorDialog("", "重工路线代码不能为空");
                    return false;
                }
                rePathVerk=pathRowData.path_ver;
                if (!rePathVerk) {
                    showErrorDialog("", "重工路线版本不能为空");
                    return false;
                }
                rsnCode = reasonRowData[0].deptId;
                if (!rsnCode) {
                    showErrorDialog("", "部门代码不能为空,请输入");
                    return false;
                }
                rsnCate = "RKRS";
                rsnDept = reasonRowData[0].data_ext;
                if (!rsnDept) {
                    showErrorDialog("", "原因代码不能为空,请输入");
                    return false;
                }
                nxPathIdFk = domObj.$nxPathIdFk.val();
                if (!nxPathIdFk) {
                    showErrorDialog("", "下一站工艺路线不能为空");
                    return false;
                }
                nxPathVerFk = domObj.$nxPathVerFk.val();
                if (!nxPathVerFk) {
                    showErrorDialog("", "下一站工艺版本不能为空");
                    return false;
                }
                nxOpeNoFk = domObj.$nxOpeNoFk.val();
                if (!nxOpeNoFk) {
                    showErrorDialog("", "当前站点不能为空");
                    return false;
                }
                iary = {
                    rsn_code        : rsnCode,
                    rsn_cate        : rsnCate,
                    rsn_dept        : rsnDept,
                    re_path_id_fk   : rePathId,
                    re_path_ver_fk  : rePathVerk,
                    nx_path_id_fk   : nxPathIdFk,
                    nx_path_ver_fk  : nxPathVerFk,
                    nx_ope_no_fk    : nxOpeNoFk,
                    ret_prd_info    : data,
                    evt_usr         : VAL.EVT_USER,
                };
                inObj = {
                    trx_id : VAL.T_FPPFORCEIN,
                    action_flg : "F",
                    iary : [iary]
                };
                outObj = comTrxSubSendPostJson(inObj);
                if (outObj.rtn_code === VAL.NORMAL) {
                    var length = rowIds.length;
                    for(var i=0;i<length;i++){
                        domObj.grids.$glassListGrd.jqGrid("delRowData",rowIds[0]);
                    }
                    showSuccessDialog("进入重工成功");
                }

            },
            delReWorkBtnfunc : function() {
                var swhTyp,rsnCode,rsnCate,rsnDept,iary,inObj,outObj;
                var reasonRowData =domObj.grids.$reasonListGrd.jqGrid("getRowData");
                if(reasonRowData.length<1){
                    showErrorDialog("", "原因代码不能为空");
                    return;
                }
                var rowIds = domObj.grids.$glassListGrd.jqGrid("getGridParam","selarrrow");
                var data = new Array();
                for (var i=0;i<rowIds.length;i++){
                    var rowData = domObj.grids.$glassListGrd.jqGrid("getRowData",rowIds[i]);
                    data.push(rowData)
                }
                if (data.length<1) {
                    showErrorDialog("", "至少选中一条屏体信息");
                    return false;
                }
                swhTyp="K";
                rsnCode = reasonRowData[0].deptId;
                if (!rsnCode) {
                    showErrorDialog("", "部门代码不能为空,请输入");
                    return false;
                }
                rsnCate = "RKRS";
                rsnDept = reasonRowData[0].data_ext;
                if (!rsnDept) {
                    showErrorDialog("", "原因代码不能为空,请输入");
                    return false;
                }
                iary = {
                    swh_typ        : swhTyp,
                    rsn_code       : rsnCode,
                    rsn_cate       : rsnCate,
                    rsn_dept       : rsnDept,
                    swh_typ        : swhTyp,
                    ret_prd_info   : data,
                    evt_usr        : VAL.EVT_USER
                };
                inObj = {
                    trx_id : VAL.T_FPPFORCEIN,
                    action_flg : "C",
                    iary : [iary]
                };
                outObj = comTrxSubSendPostJson(inObj);
                if (outObj.rtn_code === VAL.NORMAL) {
                    var length = rowIds.length;
                    for(var i=0;i<length;i++){
                        domObj.grids.$glassListGrd.jqGrid("delRowData",rowIds[0]);
                    }
                    showSuccessDialog("取消重工成功");
                }
            },
            stopReWorkBtnfunc : function() {
                var swhTyp,rsnCode,rsnCate,rsnDept,iary,inObj,outObj;
                var reasonRowData =domObj.grids.$reasonListGrd.jqGrid("getRowData");
                if(reasonRowData.length<1){
                    showErrorDialog("", "原因代码不能为空");
                    return;
                }
                var rowIds = domObj.grids.$glassListGrd.jqGrid("getGridParam","selarrrow");
                var data = new Array();
                for (var i=0;i<rowIds.length;i++){
                    var rowData = domObj.grids.$glassListGrd.jqGrid("getRowData",rowIds[i]);
                    data.push(rowData)
                }
                if (data.length<1) {
                    showErrorDialog("", "至少选中一条屏体信息");
                    return false;
                }
                swhTyp="K";
                rsnCode = reasonRowData[0].deptId;
                if (!rsnCode) {
                    showErrorDialog("", "部门代码不能为空,请输入");
                    return false;
                }
                rsnCate = "RKRS";
                rsnDept = reasonRowData[0].data_ext;
                if (!rsnDept) {
                    showErrorDialog("", "原因代码不能为空,请输入");
                    return false;
                }
                iary = {
                    swh_typ        : swhTyp,
                    rsn_code       : rsnCode,
                    rsn_cate       : rsnCate,
                    rsn_dept       : rsnDept,
                    swh_typ        : swhTyp,
                    ret_prd_info   : data,
                    evt_usr        : VAL.EVT_USER
                };
                inObj = {
                    trx_id : VAL.T_FPPFORCEIN,
                    action_flg : "A",
                    iary : [iary]
                };
                outObj = comTrxSubSendPostJson(inObj);
                if (outObj.rtn_code === VAL.NORMAL) {
                    var length = rowIds.length;
                    for(var i=0;i<length;i++){
                        domObj.grids.$glassListGrd.jqGrid("delRowData",rowIds[0]);
                    }
                    showSuccessDialog("终止重工成功");
                }
            }
        }
        // 主页面grid初始化
        var iniGridInfo = function() {
            domObj.grids.$reasonListGrd.jqGrid({
                url : "",
                datatype : "local",
                mtype : "POST",
                height : 100,
                width : domObj.grids.$reasonListDiv.width(),
                autowidth : true,
                shrinkToFit:false,
                autoScroll: false,
                resizable : true,
                loadonce : true,
                viewrecords : true,
                rownumbers : true,
                rowNum : 20,
                emptyrecords : true,
                multiselect : false,
                pager : domObj.grids.$reasonListPg,
                colModel : [ {
                    name : 'deptId',
                    index : 'deptId',
                    label : '部门代码',
                    width : 270
                }, {
                    name : 'data_ext',
                    index : 'data_ext',
                    label : '原因代码',
                    width : 270
                }, {
                    name : 'data_desc',
                    index : 'data_desc',
                    label : '原因代码说明',
                    width : 470
                },]
            });
            domObj.grids.$glassListGrd.jqGrid({
                url : "",
                datatype : "local",
                mtype : "POST",
                height : 360,
                width : domObj.grids.$glassListDiv.width(),
                autowidth : true,
                shrinkToFit:false,
                autoScroll: false,
                resizable : true,
                loadonce : true,
                viewrecords : true,
                rownumbers : true,
                rowNum : 20,
                emptyrecords : true,
                multiselect : true,
                pager : domObj.grids.$glassListPg,
                colModel : [ {
                    name : 'prd_seq_id',
                    index : 'prd_seq_id',
                    label : '屏体代码',
                    width : 180
                }, {
                    name : 'wo_id_fk',
                    index : 'wo_id_fk',
                    label : '工单信息',
                    width : 150
                },{
                    name : 'mdl_id_fk',
                    index : 'mdl_id_fk',
                    label : '产品代码',
                    width : 180
                }, {
                    name : 'prd_stat',
                    index : 'prd_stat',
                    label : '屏体状态',
                    width : 115
                }, {
                    name  : 'prd_qty',
                    index : 'prd_qty',
                    label : '屏体数量',
                    width : 125
                }, {
                    name :  'proc_id_fk',
                    index : 'proc_id_fk',
                    label : '制程代码',
                    width : 145
                }, {
                    name : 'prd_grade',
                    index : 'prd_grade',
                    label : '屏体等级',
                    width : 125
                }, {
                    name : 'path_id_fk',
                    index : 'path_id_fk',
                    label : '工艺路线代码',
                    hidden: true,
                    width : 145
                }, {
                    name : 'ope_id_fk',
                    index : 'ope_id_fk',
                    label : '站点代码',
                    hidden: true,
                    width : 145
                }],
                onSelectRow : function(rowId) {
                    var rowData = domObj.grids.$glassListGrd.jqGrid("getRowData", rowId);
                    var prd_seq_Id = rowData.prd_seq_id;
                    inObj={
                        trx_id : VAL.T_FIPINQSHT,
                        action_flg : "Q",
                        prd_seq_id : prd_seq_Id
                    }
                    outObj = comTrxSubSendPostJson(inObj);
                    if (outObj.rtn_code === VAL.NORMAL) {
                        domObj.$prdSeqId.val(prd_seq_Id);
                        domObj.$prdStat.val(outObj.prd_stat);
                        domObj.$prdGrade.val(outObj.prd_grade);
                        domObj.$mdlIdFk.val(outObj.mdl_id_fk);
                        domObj.$woIdFk.val(outObj.wo_id_fk);
                        domObj.$crOpeNoFk.val(outObj.cr_ope_no_fk);
                        domObj.$nxOpeNoFk.val(outObj.ope_no_fk);
                        domObj.$nxProcIdFk.val(outObj.proc_id_fk);
                        domObj.$nxPathIdFk.val(outObj.path_id_fk);
                        domObj.$nxPathVerFk.val(outObj.path_ver_fk);
                        domObj.$crPathIdFk.val(outObj.cr_path_id_fk);
                        domObj.$crPathVerFk.val(outObj.cr_path_ver_fk);
                    }
                }
            });
        }
        // 重工代码对话框grid初始化
        var inModelGrid = function() {
            domObj.dialogs.$modalReasonListGrd
                .jqGrid("clearGridData");
            domObj.dialogs.$reModalReasonListGrd
                .jqGrid("clearGridData");
            domObj.dialogs.$rePathListGrd.jqGrid({
                url : "",
                datatype : "local",
                mtype : "POST",
                height : 400,
                // width:domObj.dialogs.rePathListDiv.width()* 0.99,
                width : 650,
                autowidth : false,
                shrinkToFit : false,
                resizable : true,
                loadonce : true,
                viewrecords : true,
                rownumbers : true,
                rowNum : 20,
                emptyrecords : true,
                multiselect : false,
                pager : domObj.dialogs.$rePathListPg,
                colModel : [{
                    name : 'path_id',
                    index : 'path_id',
                    label : '重工路线名称',
                    width : 150
                }, {
                    name : 'path_ver',
                    index : 'path_ver',
                    label : '重工路线版本',
                    width : 150
                }, {
                    name : 'path_dsc',
                    index : 'path_dsc',
                    label : '重工路线描述',
                    width : 150
                },{
                    name : 'path_stat',
                    index : 'path_stat',
                    label : '重工路线状态',
                    width : 150
                } ],
            });
            domObj.dialogs.$modalReasonListGrd
                .jqGrid({
                    url : "",
                    datatype : "local",
                    mtype : "POST",
                    height : 300,
                    width : 400,
                    autowidth : false,
                    shrinkToFit : false,
                    resizable : true,
                    loadonce : true,
                    viewrecords : true,
                    rownumbers : true,
                    rowNum : 20,
                    emptyrecords : true,
                    multiselect : false,
                    pager : domObj.dialogs.$modalReasonListPg,
                    colModel : [ {
                        name : 'deptId',
                        index : 'deptId',
                        label : '部门代码',
                        hidden : true,
                        width : 100
                    }, {
                        name : 'data_ext',
                        index : 'data_ext',
                        label : '原因代码',
                        width : 150
                    }, {
                        name : 'data_desc',
                        index : 'data_desc',
                        label : '原因代码说明',
                        width : 180
                    } ],
                    onSelectRow : function(rowId, status) {
                        var deptId = $.trim(domObj.dialogs.$deptId.val());
                        if(!deptId){
                            showErrorDialog("", "请先选择部门代码");
                            return false;
                        }
                        var rowId= domObj.dialogs.$modalReasonListGrd
                            .jqGrid("getGridParam", "selrow");
                        var rowData = domObj.dialogs.$modalReasonListGrd.jqGrid(
                            "getRowData", rowId);
                        rowData.deptId =deptId;
                        setGridInfo(rowData, "#reModalReasonListGrd");
                    }
                });
            domObj.dialogs.$reModalReasonListGrd.jqGrid({
                url : "",
                datatype : "local",
                mtype : "POST",
                height : 400,
                width : 400,
                autowidth : false,
                shrinkToFit : false,
                resizable : true,
                loadonce : true,
                viewrecords : true,
                rownumbers : true,
                rowNum : 20,
                emptyrecords : true,
                multiselect  : false,
                pager : domObj.dialogs.$reModalReasonListPg,
                colModel : [ {
                    name : 'deptId',
                    index : 'deptId',
                    label : '部门代码',
                    width : 100
                }, {
                    name : 'data_ext',
                    index : 'data_ext',
                    label : '原因代码',
                    width : 100
                }, {
                    name : 'data_desc',
                    index : 'data_desc',
                    label : '原因代码说明',
                    width : 100,
                } ]
            });
        }
        // 选中重工代码的事件
        domObj.$frPathIdFk.on("select2:opening",function(e) {
            domObj.dialogs.$rePathDialog.modal({
                backdrop : true,
                keyboard : false,
                show : false
            });
            domObj.dialogs.$rePathDialog.modal("show");
        });
        var dialogFnc = {
            reasonSureFnc : function() {
                var Data = domObj.dialogs.$reModalReasonListGrd.jqGrid("getRowData");
                if(Data.length<1){
                    showErrorDialog("", "请选择一条原因代码");
                    return false;
                }
                setGridInfo(Data, "#reasonListGrd");
                domObj.dialogs.$addReasonDialog.modal("hide");
            },
            rePathSureFnc : function() {
                var rowId= domObj.dialogs.$rePathListGrd
                    .jqGrid("getGridParam", "selrow");
                if(rowId==null){
                    showErrorDialog("", "请选择一条重工代码");
                    return false;
                }
                var rowData = domObj.dialogs.$rePathListGrd.jqGrid("getRowData", rowId);
                SelectDom.setSelect(domObj.$frPathIdFk, rowData.path_id);
                domObj.dialogs.$rePathDialog.modal("hide");
            }
        }

        var iniButtonAction = function() {
            domObj.buttons.$query_btn.click(function() {
                btnFunc.queryBtnfunc();
            });
            // 确认按钮绑定click事件函数
            domObj.dialogs.$rePathDialog_sureBtn.bind('click',
                dialogFnc.rePathSureFnc);
            domObj.buttons.$selectReason_btn.click(function() {
                btnFunc.selectReasonBtnfunc();
            });
            domObj.buttons.$deleteReason_btn.click(function() {
                btnFunc.deleteReasonBtnfunc();
            });
            // 确认按钮绑定click事件函数
            domObj.dialogs.$reasonDialog_sureBtn.bind('click',
                dialogFnc.reasonSureFnc);
            domObj.buttons.$delReWork_btn.click(function() {
                btnFunc.delReWorkBtnfunc();
            });
            domObj.buttons.$reWork_btn.click(function() {
                btnFunc.reWorkBtnfunc();
            });
            domObj.buttons.$stopReWork_btn.click(function() {
                btnFunc.stopReWorkBtnfunc();
            });
        }
        var clearDataAction = function() {
            SelectDom.setSelect(domObj.$frPathIdFk,"");
            domObj.$prdSeqId.val("");
            domObj.$prdStat.val("");
            domObj.$prdGrade.val("");
            domObj.$mdlIdFk.val("");
            domObj.$woIdFk.val("");
            domObj.$crOpeNoFk.val("");
            domObj.$nxOpeNoFk.val("");
            domObj.$nxProcIdFk.val("");
            domObj.$nxPathIdFk.val("");
            domObj.$nxPathVerFk.val("");
            domObj.$crPathIdFk.val("");
            domObj.$crPathVerFk.val("");
            $("#reasonListGrd").jqGrid('clearGridData');
            $("#glassListGrd").jqGrid('clearGridData');
            $("#modalReasonListDiv").jqGrid('clearGridData');
            $("#reModalReasonListDiv").jqGrid('clearGridData');
            $("#rePathListDiv").jqGrid('clearGridData');
        }
        var otherActionBind = function(){
            //Stop from auto commit
            $("form").submit(function(){
                return false;
            });

        };
        domObj.$prdSeqIdFk.keydown(function(event) {
            if (event.which == 13) {
                btnFunc.queryBtnfunc();
            }
        });
        function initFunc() {
            iniGridInfo();
            iniButtonAction();
            inModelGrid();// 初始化dailog中的grids
            otherActionBind();
            toolFunc.iniRewokPath();
        }
        initFunc();
        //enter
        /*document.onkeydown=function(event){
            var e = event || window.event || arguments.callee.caller.arguments[0];
            if(e && e.keyCode==13){ // 按 enter
                $('.bootbox').modal("hide");
            }
        }*/
        //表格自适应
        function resizeFnc() {
            var offsetBottom, divWidth,offsetBottom1, divWidth1;
            divWidth = $("#rightDiv1").width();
            offsetBottom = $("#rightDiv1").offset().top;
            $("#rightDiv1").height(offsetBottom * 0.95);
            $("#reasonListGrd").setGridWidth(divWidth * 0.99);
            $("#reasonListGrd").setGridHeight(offsetBottom * 0.95);
            //2
            divWidth1 = $("#rightDiv1").width();
            offsetBottom1 =  $(window).height() - $("#rightDiv1").offset().top;
            $("#rightDiv1").height(offsetBottom1 * 0.95);
            $("#glassListGrd").setGridWidth(divWidth1 * 0.99);
            $("#glassListGrd").setGridHeight(offsetBottom1 * 0.65 - 51);
        };

        resizeFnc();
        $(window).resize(function () {
            resizeFnc();
        });
    })